import request from "@/common/http";
import menuListResponse from './mock/menu.json'
import {MenuItem} from "@/pages/system/menu/constant";

export function apiGetMenuList(params: any, useMock?: boolean): Promise<any> {
  if (useMock) {
    return Promise.resolve(menuListResponse)
  }
  return request.get('/gateway/ums/sys-role', params)
}


export async function queryMenu(params?: any) {
  return request('/api/sys/menu/list', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function removeMenuOne(params: { id: number }) {
  return request('/api/sys/menu/delete', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function removeMenu(params: { ids: number[] }) {
  return request('/api/sys/menu/delete', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function addMenu(params: MenuItem) {
  return request('/api/sys/menu/add', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function updateRule(params: MenuItem) {
  return request('/api/sys/menu/update', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}
